package com.internetCafes.spms.common.AIRecognize.analyzer;

import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @author LinYe
 * @date 2020/10/14
 */
@Component
public class AnalyzerManager {

    public List<Analyzer> analyzerList= new ArrayList<Analyzer>();

    private static AnalyzerManager instance = new AnalyzerManager();

    public Analyzer getAnalyzer(String urlOrWord){
        for (int i = 0; i < analyzerList.size(); i++) {
            Analyzer analyzer = analyzerList.get(i);
            if (analyzer.match(urlOrWord)){
                return analyzer;
            }
        }
        return null;
    }

    public void register(Analyzer analyzer){
        analyzerList.add(analyzer);
    }

    public static AnalyzerManager getInstance(){
        return  instance;
    }

    private AnalyzerManager() {
    }
}
